/*
  LinPVR - Linux Personal Video Recorder
  Copyright (C) 2006 Kamil Pawlowski <kamilpe@gmail.com>

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/
#ifndef _CAPTURE_H_
#define _CAPTURE_H_

#include <glib.h>

struct capture_s;

/******************************************
   abstract class for data processors 
*******************************************/

typedef int (*vidproc_callback) (struct capture_s *capture);

typedef struct video_procesor_s {
  /* data for internal use */
  void             *encoder;
  void             *device;

  /* callbacks for operations */
  vidproc_callback  iframe;      /* fill rgb_buffer from device */
  vidproc_callback  oframe;      /* write rgb_buffer to encoder */
  vidproc_callback  init_device; /* init video device */
  vidproc_callback  stop_device; /* stop video device */

  /* processing data */
  unsigned char    *rgb_buffer;
  int               frame_ready;
  GThread          *thread;
} video_procesor_t;

typedef struct audio_procesor_s {
  /* audio not supported */
} audio_procesor_t;

/****************************************
             main class 
*****************************************/

#define CAPTURE_NO          0
#define CAPTURE_STARTING    1
#define CAPTURE_WORK        2
#define CAPTURE_STOPPING    3

typedef struct capture_s {
  /* video procesor */
  float             fps;
  int               width;
  int               height;
  int               vb;
  video_procesor_t  video_proc;

  /* audio processor */
  int               rate;
  int               channels;
  int               ab;
  audio_procesor_t  audio_proc;

  /* statistics */
  int  state;
  long timestamp;
  long transfered;
} capture_t;


/***************************************************/

int  capture_create(capture_t *capture, int width, int height);
int  capture_start(capture_t *capture);
int  capture_stop(capture_t *capture);
void capture_destroy(capture_t *capture);

#endif
